<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        
        <link rel="stylesheet" type="text/css" href="styles.css" />
        
        <script type="text/javascript" src="../src/TinyC5-0.7.js"></script>
        <script type="text/javascript">
            /**
             * Example03 - Keftales
             * 
             * This example is forked from Shockwave's entry of the Short Intro Challenge:
             * http://www.dbfinteractive.com/forum/index.php?topic=276.0
             */
            function Example03() 
            {
                // Declase vars
                var tinyC5, index, gadd=0, gadd2=0, zf=0, mvx=0, mvy = 0, pwr=0;
                
                // Setup TinyC5
                tinyC5 = new TinyC5();
                var args = { 
                    scale: 2, 
                    width: tinyC5.isMobile()  ? 80 : 320,
                    height: tinyC5.isMobile() ? 50 : 200,
                    supportMobile: true,
                    container: document.getElementById( 'tinyC5_container' ), 
                    title: 'Keftales - TinyC5 Example #03' 
                };
                tinyC5.init( args );
                
                // Perform effect
                tinyC5.update = function() 
                {
                    index = 0;
                    gadd +=3;
                    gadd2 +=20;
                    zf = 0.11 + ( 0.1 * Math.sin( gadd / 191 ) );
                    mvx = 499 * Math.sin( gadd/153 );
                    mvy = 499 * Math.cos( gadd/131 );
                    for( var y=0; y < tinyC5.HEIGHT; y++ ) {
                        for ( var x=0; x < tinyC5.WIDTH; x++ ) {
                            pwr = 120+119*Math.sin((((x+mvx)*(y+mvy))+gadd2) * zf);
                            tinyC5.pixels[ index++ ] = pwr;
                            tinyC5.pixels[ index++ ] = pwr*y >> 9;
                            index++;    // Skip blue                            
                            index++;    // Skip alpha, its 255 by default
                        }                        
                    }
                };
                
                // Get the canvas object
                var canvas = tinyC5.getCanvas();
                canvas.addEventListener( tinyC5.FAST_CLICK_EVENT, function(e) { 
                    tinyC5.setFullscreen( !tinyC5.isFullscreen() );
                } );
                
                // Start the show
                tinyC5.start();
            }    
        </script>
            
    </head>
    <body onload="Example03();">
        <div id="container">
            <div id="tinyC5_container">
            </div>
        </div>	
        <div id="footer">
            Keftales. Original code by Shockwave^Codigos | Created with <a href="http://www.dbfinteractive.com/forum/index.php?topic=5397.0">TinyC5</a>
        </div>        
    </body>
</html>
